//
//  WWYReadDetailCell.m
//  Pianke
//
//  Created by Daydream on 15/12/29.
//  Copyright © 2015年 dada. All rights reserved.
//

#import "WWYReadDetailCell.h"
#import "WWYReadDetailModel.h"

@implementation WWYReadDetailCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self makeCell];
    }
    return self;
}

- (void)makeCell{
    self.title = [[UILabel alloc] init];
    [self.contentView addSubview:self.title];
    self.title.font = [UIFont fontWithName:@"Helvetica-Bold" size:17];
    [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(@0);
        make.left.mas_equalTo(@10);
        make.right.mas_equalTo(@-10);
        make.height.mas_equalTo(@40);
        
    }];
    
    self.back = [[UIImageView alloc] init];
    [self.contentView addSubview:self.back];
    
    self.content = [[UILabel alloc] init];
    self.content.font = [UIFont systemFontOfSize:15];
    self.content.numberOfLines = 0;
    [self.contentView addSubview:self.content];

    [self.back mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.title);
        make.bottom.mas_equalTo(@-10);
        make.top.mas_equalTo(self.title.mas_bottom);
        make.width.mas_equalTo(self.content);
    }];
    
    [self.content mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.back.mas_right).offset(5);
        make.bottom.mas_equalTo(self.back);
        make.right.mas_equalTo(self.title);
        make.top.mas_equalTo(self.title.mas_bottom);
        make.width.mas_equalTo(self.back);
    }];

}

- (void)setModel:(WWYReadDetailModel *)model{
    if (_model != model){
        _model = model;
    }
    
    [self.back sd_setImageWithURL:[NSURL URLWithString:self.model.coverimg]];
    self.content.text = self.model.content;
    self.title.text = self.model.title;
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
